package dao

import (
	"go_web_todo/models"
)

func UserRegister(user *models.User) error {
	return DB.Create(&user).Error
}

// 检查是否已经注册过
func CheckUserRegister(userName string, user *models.User, count int64) error {
	return DB.Model(&models.User{}).Where("user_name=?", userName).First(&user).Error
}

//登录,根据用户
func FindUserByName(userName string, user *models.User) error {
	return DB.Where("user_name=?", userName).First(&user).Error
}
func FindUserByID(id uint, user *models.User) error {
	return DB.Model(&models.User{}).First(&user, id).Error
}
